import yaml
import os
# def read_yaml():
#     with open(r"D:\python\python program\pythonProject1\pytest知识体系\datas\login.yaml",'r',encoding='utf-8') as f:
#       return yaml.safe_load(f)
#
# #调试代码
# if __name__=="__main__":
#     res=read_yaml()
#     print(res)

# ##获取当前文件的完整路径
# print(__file__)
#
# ##获取当前文件的上一层路径 os.path.dirname()
# print(os.path.dirname(__file__))
#
# ##拼接路径 os.path.join()
# root_path=os.path.dirname(__file__)
# new_path=os.path.join(root_path,"data","test.yaml")
# print(new_path)

# ##把login.yaml 路径整出来
# root_path=(os.path.dirname(os.path.dirname(__file__)))
# new_path=os.path.join(root_path,"datas","login.yaml")
# print(new_path)

def get_path(filename):
    root_path=(os.path.dirname(os.path.dirname(__file__)))
    new_path=os.path.join(root_path,"datas",filename)
    return new_path

def read_yaml(filename):
    with open(get_path(filename),'r',encoding='utf-8') as f:
        return yaml.safe_load(f)

if __name__=="__main__":
    res=read_yaml("login.yaml")
    print(type(res))
    print(res)

